<?php
$_GET['modele'] = 'page';
$ext = modele_permalien::getExtensionByModele('page');
$template = 'presentation';
$lien = 'presentation'.$ext;
$title = 'Présentation';

$publication = modele_page::findByPermalien($lien,'page');
if($publication===null){
    $publication = new modele_page();
    $datas = array(
        'title'=>$title,
        'lien'=>$lien,
        'template'=>PWE::getDefaultTemplate()
    );
    $publication->setDatas($datas);
    $action = 'create';
}else{
    $action = 'update';
}

$data = $publication->getDatas();
$data['permalien'] = $publication->getPermalien()->getCleanedLien(false);
?>
<h1>Modifier la page "Contact"</h1>
<hr style="margin: 5px 0 15px 0;">
<form style="margin: 12px 0;" method="post" enctype="multipart/form-data" action="?template=<?php echo $template; ?>&action=<?php echo $action; ?>&modele=page&do=1&modele_id=<?php echo (isset($data['id']))?$data['id']:''; ?>">
    <div class="columns ten">
        <p style="margin: 10px 0;"><input type="text" name="modele_title" value="<?php echo (isset($data['title']))?$data['title']:''; ?>" class="titreModele"  onblur="javascript:generatePermalien($(this).val());"/></p>
        <p style="margin: 10px 0;"><?php echo PWE::getBaseURL(); ?><input id="permalien" type="text" name="modele_lien" value="<?php echo (isset($data['permalien']))?$data['permalien']:''; ?>" style="font-size: 1.2em;" onblur="javascript:validPermalien($(this).val());"/><?php echo $ext; ?></p>
        <h3>Contenu</h3>
        <textarea class="editor" name="modele_content"><?php echo (isset($data['content']))?$data['content']:''; ?></textarea><br/>
        <p style="margin: 10px 0;">Titre SEO : <input type="text" maxlength="255" name="modele_titre_seo" value="<?php echo (isset($data['titre_seo']))?$data['titre_seo']:''; ?>" style="width: 450px;"/></p>
        <p style="margin: 10px 0;">Description SEO : <textarea  maxlength="512" name="modele_description_seo" style="height: 100px;"><?php echo (isset($data['description_seo']))?$data['description_seo']:''; ?></textarea></p>
        <div align="right">
            <input type="submit" value="Enregistrer" class="pwe-ui-btn"/> 
            <?php if(isset($data['id']) && $data['id']>0): ?><a href="<?php echo $data['url']; ?>" target="_blank" title="voir" class="pwe-ui-btn">voir</a><?php endif; ?>
        </div>
        <?php include('../admin/include/inc/redirectionManager.inc.php'); ?>
    </div>
    <div class="columns five">
        <h3>Statut</h3>
        <select name="modele_statut_id">
            <option value="1" <?php echo(isset($data['statut_id']) && $data['statut_id']=='1')?'selected="selected"':''; ?>>Brouillon</option>
            <option value="2" <?php echo(isset($data['statut_id']) && $data['statut_id']=='2')?'selected="selected"':''; ?>>Publié</option>
        </select><br/><br/>
        <?php include('../admin/include/inc/mediaManager.inc.php'); ?>
        <input type="hidden" name="modele_template" value="<?php echo PWE::getDefaultTemplate(); ?>" />
        <input type="hidden" name="modele_id" value="<?php echo (isset($data['id']))?$data['id']:''; ?>" />
    </div>
</form>